<?php

namespace addons\daily;

use app\common\library\Menu;
use think\Addons;

/**
 * 插件
 */
class Daily extends Addons
{

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        //插件daily后台管理的菜单
        //先在后台生成和配置好菜单，再导出复制到插件文件中 
        $menu = [
          [
            'name' => 'daily',
            'title' => '日报管理',
            'icon' => 'fa fa-list',
            'sublist' => 
            [
              [
                'name' => 'daily/daily_log',
                'title' => '日报',
                'icon' => 'fa fa-circle-o',
                'weigh' => 0,
                'sublist' => 
                [
                  [
                    'name' => 'daily/daily_log/index',
                    'title' => '查看',
                    'icon' => 'fa fa-circle-o',
                    'weigh' => 0,
                  ],
                  [
                    'name' => 'daily/daily_log/add',
                    'title' => '添加',
                    'icon' => 'fa fa-circle-o',
                    'weigh' => 0,
                  ],
                  [
                    'name' => 'daily/daily_log/edit',
                    'title' => '编辑',
                    'icon' => 'fa fa-circle-o',
                    'weigh' => 0,
                  ],
                  [
                    'name' => 'daily/daily_log/del',
                    'title' => '删除',
                    'icon' => 'fa fa-circle-o',
                    'weigh' => 0,
                  ],
                  [
                    'name' => 'daily/daily_log/multi',
                    'title' => '批量更新',
                    'icon' => 'fa fa-circle-o',
                    'weigh' => 0,
                  ],
                ],
              ],
            ],
          ],
        ];
        Menu::create($menu);
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete('daily');
        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {
        
        Menu::enable('daily');
        return true;
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {
        
        Menu::disable('daily');
        return true;
    }

}
